<%@ page contentType="text/html; charset=UTF-8" %>
<script type="text/javascript" src="<%=session.getServletContext().getContextPath() %>/js/jquery.form.js"></script>
<script type="text/javascript">
/* jQuery(document).ready(function(){
	// binds form submission and fields to the validation engine
	jQuery("#formDefault").validationEngine();
});  */

/**
*
* @param {jqObject} the field where the validation applies
* @param {Array[String]} validation rules for this field
* @param {int} rule index
* @param {Map} form options
* @return an error string if validation failed
*/
function checkHELLO(field, rules, i, options){
	if (field.val() != "") {
		// this allows to use i18 for the error msgs
		if(field.val() != 'a') {
			return "* 153893";
		}
		
		//return options.allrules.validate2fields.alertText;
	}
} 
</script>		
<script type="text/javascript">

    $(function () {

        $('#testCreateSave').click(function(){
        	
        	if(isValidationField('formDefault')) {
        		if(confirm('ยืนยันการบันทึกข้อมูล')) {
        			ajaxSubmitFormSimple($('#collapse'),'testManageAction_testCreateSave.action',$('#formDefault').serialize(),false);
        		}
        	}
        	
        });
        
		$('#testEditSave').click(function(){
        	
        	if(isValidationField('formDefault')) {
        		if(confirm('ยืนยันการบันทึกข้อมูล')) {
        			ajaxSubmitFormSimple($('#collapse'),'testManageAction_testEditSave.action',$('#formDefault').serialize(),false);
        		}
        	}
        	
        });
        
        $('#testSearch').click(function(){
        	ajaxSubmitFormSimple($('#divSearch'),'testManageAction_testSearch.action',$('#formDefault').serialize(),false);
        });
        
    });
    
    function testEdit(val) {
    	$('#id').val(val);
    	ajaxSubmitFormSimple($('#divForEdit'),'testManageAction_testEditInit.action',$('#formDefault').serialize(),false);
    }
    
    function testDelete(val) {
    	if(confirm('ยืนยันการลบข้อมูล')) {
    		$('#id').val(val);
    		ajaxSubmitFormSimple($('#collapse'),'testManageAction_testDelete.action',$('#formDefault').serialize(),false);
    	}
    }
    
 
</script>